/*
 * JPMetaDados.java
 *
 * Created on 17 de Maio de 2008, 18:26
 */
package view.jpanel;

//import b_Controle.*;
//import c_Modelo.Regras.FacadeFactory;
import controller.FacadeHost;
import controller.Host;
import interfaces.Base;
import java.awt.Component;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

/**
 *
 * @author  Rafael
 */
public class JPanelTabbed extends javax.swing.JPanel implements Observer {

//    private FacadeSwing facadeSwing;
//    private FacadeSalvar facadeSalvar;

//    @Deprecated
//    public static final int jPPreviaDados = -1;
//    @Deprecated
//    public static final int jPConfiguracaoAlgoritmo = -1;
    
//    public static final int jPMetaDados = 0;
//    public static final int jPSelecionaColunas = 1;
//    public static final int jPSelecionaTecnica = 2;
//    public static final int jPAndamentoTreinamento = 3;
//    public static final int jPResultadoAlgoritmo = 4;
//    public static final int jPEstatisticas = 5;
//    public static final int jPTeste = 6;



    
    public static final int JPANELPREPROCESS        = 0;
    public static final int JPANELCLASSIFY          = 1;
    public static final int JPANELCLUSTER           = 2;
    public static final int JPANELASSOCIATE         = 3;
    public static final int JPANELSELECTATRIBUTES   = 4;
    public static final int JPANELVISUALIZE         = 5;


    /** Creates new form JPMetaDados */
    public JPanelTabbed() {
        initComponents();
//        facadeSwing = FacadeFactory.getFacadeSwing();
//        facadeSalvar = FacadeFactory.getFacadeSalvar();
        FacadeHost.getHost().addObserver(this);

        jTabbedPane1.addTab("Pré-Processamento", new JPanelPreprocess());

        jTabbedPane1.addTab("Classificação", new JPanelClassify());
        setEnabledAt(JPANELCLASSIFY, false);

        jTabbedPane1.addTab("Cluster", (JPanel) null);
        setEnabledAt(JPANELCLUSTER, false);

        jTabbedPane1.addTab("Regras de Associação", (JPanel) null);
        setEnabledAt(JPANELASSOCIATE, false);

        jTabbedPane1.addTab("Seleção de Atributos", (JPanel) null);
        setEnabledAt(JPANELSELECTATRIBUTES, false);

        jTabbedPane1.addTab("Visualizar", new JPanelVisualise());
        setEnabledAt(JPANELVISUALIZE, false);


//        jTabbedPane1.addTab("Conexão", new JPMetaDados());
//
//        jTabbedPane1.addTab("Dados", new JPSelecionaColunas());
//        setEnabledAt(jPSelecionaColunas, false);
//
//        /*jTabbedPane1.addTab("Previa", new JPPreviaDados());
//        setEnabledAt(2, false);*/
//
//        jTabbedPane1.addTab("Tecnicas", new JPSelecionaTecnica());
//        setEnabledAt(jPSelecionaTecnica, false);
//
////        jTabbedPane1.addTab("Configuracao", (JPanel) null);
////        setEnabledAt(jPConfiguracaoAlgoritmo, false);
//
//        jTabbedPane1.addTab("Treinamento", (JPanel) null);
//        setEnabledAt(jPAndamentoTreinamento, false);
//
//        jTabbedPane1.addTab("Resultados", (JPanel) null);
//        setEnabledAt(jPResultadoAlgoritmo, false);
//
//        jTabbedPane1.addTab("Estatisticas", (JPanel) new JPEstatisticas());
//        setEnabledAt(jPEstatisticas, false);
//
//        jTabbedPane1.addTab("Testes", (JPanel) null);
//        setEnabledAt(jPTeste, false);
//
//        facadeSwing.setAbas(jTabbedPane1);
//        facadeSwing.setJPAbas(this);
//
//        facadeSalvar.setAbas(jTabbedPane1);
//        facadeSalvar.setJPAbas(this);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();

        jTabbedPane1.setFont(new java.awt.Font("Calibri", 0, 12));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 761, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
//
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane jTabbedPane1;
    // End of variables declaration//GEN-END:variables
    public void setEnabledAt(int i, boolean a) {
        jTabbedPane1.setEnabledAt(i, a);
    }

    /**
     * sets the tab
     * @param index
     * @param jPanel
     */
    public void setAba(int index, Component jPanel) {
        jTabbedPane1.setComponentAt(index, (Component) jPanel);
    }

    /**
     * returns the tabbed
     * @return
     */
    public JTabbedPane getJTabbedPane1() {
        return jTabbedPane1;
    }

    /**
     * return the tab
     * @param index
     * @return
     */
    public Component getAba(int index) {
        return jTabbedPane1.getComponentAt(index);
    }

    /**
     * returns the selected component
     * @return
     */
    public Component getSelectedConponent(){
        return jTabbedPane1.getSelectedComponent();
    }

    /**
     * update
     * @param o
     * @param o1
     */
    public void update(Observable o, Object o1) {
        if(o instanceof Host){
            Host h = (Host)o;
            if((o1 instanceof Base) && ((Base)o1).hasMeta()){
                setEnabledAt(JPANELCLASSIFY, true);
                revalidate();
            }
        }
    }
}
